package com.effectiv.gooruda.rest.api.controller;

import org.springframework.social.facebook.api.Facebook;
import org.springframework.social.facebook.api.FacebookProfile;
import org.springframework.social.facebook.api.ImageType;
import org.springframework.social.facebook.api.PagedList;
import org.springframework.social.facebook.api.Reference;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

@Controller
@RequestMapping("/api/facebook/user")
public class FacebookUserOperations {
	
	//UC-FB-001
	@RequestMapping(value="/getuserpermissions", method=RequestMethod.GET)
	public PagedList<String> getUserPermissions(Facebook facebook) {
		return facebook.userOperations().getUserPermissions();
	}

	@RequestMapping(value="/getuserprofile", method=RequestMethod.GET)
	public FacebookProfile getUserProfile(Facebook facebook) {
		return facebook.userOperations().getUserProfile();
	}

	@RequestMapping(value="/getuserprofile/{userId}", method=RequestMethod.GET)
	public FacebookProfile getUserProfile(String userId, Facebook facebook) {
		return facebook.userOperations().getUserProfile(userId);
	}

	@RequestMapping(value="/getuserprofileimage", method=RequestMethod.GET)
	public byte[] getUserProfileImage(Facebook facebook) {
		return facebook.userOperations().getUserProfileImage();
	}

	@RequestMapping(value="/getuserprofileimage/{userId}", method=RequestMethod.GET)
	public byte[] getUserProfileImage(String userId, Facebook facebook) {
		return facebook.userOperations().getUserProfileImage(userId);
	}

	@RequestMapping(value="/getuserprofileimage/{type}", method=RequestMethod.GET)
	public byte[] getUserProfileImage(ImageType imageType, Facebook facebook) {
		return facebook.userOperations().getUserProfileImage(imageType);
	}

	@RequestMapping(value="/getuserprofileimage/{userId}/{type}", method=RequestMethod.GET)
	public byte[] getUserProfileImage(String userId, ImageType imageType, Facebook facebook) {
		return facebook.userOperations().getUserProfileImage(userId, imageType);
	}

	@RequestMapping(value="/search/{query}", method=RequestMethod.GET)
	public PagedList<Reference> search(String query, Facebook facebook) {
		return facebook.userOperations().search(query);
	}

}
